package com.haina.vote.entity;

import com.haina.vote.utils.DateUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

public class IpInfo {
    //主键
    private Integer id;
    //ip地址
    private String ipaddress;
    //此ip的请求次数
    private Integer number;
    //对于的投票信息
    private Vote vote;
    //此ip的上次请求时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date request_time;
    //请求时间显示字符串
    private String request_timeStr;
    //此ip本次投票对应的问卷id
    private Integer vote_id;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getIpaddress() {
        return ipaddress;
    }

    public void setIpaddress(String ipaddress) {
        this.ipaddress = ipaddress;
    }

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public Date getRequest_time() {
        return request_time;
    }

    public void setRequest_time(Date request_time) {
        this.request_time = request_time;
    }

    public Integer getVote_id() {
        return vote_id;
    }

    public Vote getVote() {
        return vote;
    }

    public void setVote(Vote vote) {
        this.vote = vote;
    }

    public void setVote_id(Integer vote_id) {
        this.vote_id = vote_id;
    }

    public String getRequest_timeStr() {
        if (request_time!=null){
            request_timeStr= DateUtils.DateToString(request_time,"yyyy-MM-dd hh:mm");
        }
        return request_timeStr;
    }

    public void setRequest_timeStr(String request_timeStr) {
        this.request_timeStr = request_timeStr;
    }

    @Override
    public String toString() {
        return "IpInfo{" +
                "id=" + id +
                ", ipaddress='" + ipaddress + '\'' +
                ", number=" + number +
                ", vote=" + vote +
                ", request_time=" + request_time +
                ", request_timeStr='" + request_timeStr + '\'' +
                ", vote_id=" + vote_id +
                '}';
    }
}
